<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>ExpectedFailures (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">testing.ExpectedFailures</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">
            Object</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Helper class for allowing some unit tests to fail, particularly designed to
mark tests that should be fixed on a given browser.

<pre class="lang-js">
var expectedFailures = new goog.testing.ExpectedFailures();

function tearDown() {
expectedFailures.handleTearDown();
}

function testSomethingThatBreaksInWebKit() {
expectedFailures.expectFailureFor(goog.userAgent.WEBKIT);

try {
...
assert(somethingThatFailsInWebKit);
...
} catch (e) {
expectedFailures.handleException(e);
}
}
</pre>
  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_testing_expectedfailures.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<pre class="inheritance">
Object
     <img src="static/images/inherit.gif">goog.testing.ExpectedFailures
</pre>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.testing.ExpectedFailures(<span></span>)
  </div>



<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_testing_ExpectedFailures.html">
              goog.testing.ExpectedFailures
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.expectFailureFor"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">expectFailureFor<span class="args">(<span class="arg">condition</span>,&nbsp;<span class="arg">opt_message</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Register to expect failure for the given condition.  Multiple calls to this
function act as a boolean OR.  The first applicable message will be used.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">condition</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to expect failure.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_message</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">Descriptive message of this expected failure.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line144">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.getExpectationMessage_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getExpectationMessage_<span class="args">()</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>&nbsp;
            A warning describing an expected failure that didn&#39;t occur.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line208">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.handleException"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">handleException<span class="args">(<span class="arg">ex</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Handle an exception, suppressing it if it is a unit test failure that we
expected.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">ex</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The exception to handle.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line168">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.handleTearDown"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">handleTearDown<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line218">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.isExceptionExpected"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isExceptionExpected<span class="args">(<span class="arg">ex</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Determines if the given exception was expected.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">ex</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The exception to check.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            Whether the exception was expected.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line158">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.reset_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">reset_<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Reset internal state.
     </div>

   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line230">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.prototype.run"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">run<span class="args">(<span class="arg">func</span>,&nbsp;<span class="arg">opt_lenient</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Run the given function, catching any expected failures.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">func</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">The function to run.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_lenient</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to ignore if the expected failures didn&#39;t occur.  In this case a warning will be logged in handleTearDown.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line190">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_testing_ExpectedFailures.html">
              goog.testing.ExpectedFailures
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.ExpectedFailures.prototype.logger_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">logger_</span>
        : <div class="fullType"><span class="type"><a href="class_goog_debug_Logger.html">goog.debug.Logger</a></span></div>
     </div>


     <div class="entryOverview">
       Logger for the expected failures.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line79">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.ExpectedFailures.setUpConsole_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.ExpectedFailures.</span><span class="entryName">setUpConsole_<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Sets up the debug console, if it isn&#39;t already set up.
     </div>

   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line111">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.ExpectedFailures.console_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.ExpectedFailures.</span><span class="entryName">console_</span>
        : <div class="fullType"><span>?</span><span class="type"><a href="class_goog_debug_DivConsole.html">goog.debug.DivConsole</a></span></div>
     </div>


     <div class="entryOverview">
       The lazily created debugging console.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_expectedfailures.js.source.html#line71">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package testing</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="goog" current="testing.ExpectedFailures"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
